{extend name="common:base" /}

{block name="page_title"}{$controllerName}列表{/block}
{block name="style"}
<!--<link href="https://cdn.staticfile.org/bootstrap-daterangepicker/3.0.3/daterangepicker.min.css" rel="stylesheet">-->
<link href="/static/daterangepicker/daterangepicker.css" rel="stylesheet">
<style>
    .img-40{width:40px;height:40px;}
</style>
{/block}
{block name="content"}
<div class="box  box-primary">
    <div class="box-header with-border">
        <div class="row">
            <div class="col-xs-11">
                <form method="get" action="{:url('index')}">
                    <div class="page-toolbar">
                            <span class="pull-left">
                                <div style="float:left">
                                    <input name="search[time_start]" type="hidden" value="{$search['time_start']}">
                                    <input name="search[time_end]" type="hidden" value="{$search['time_end']}">
                                </div>
                                <div class="btn-group btn-group-sm daterange-box" style="padding-right:0;">
                                    <button style="width:240px" class="btn btn-default daterange daterange-time btn-sm" type="button">
                                        <span class="date-title">注册时间</span>
                                    </button>
                                    <button class="btn btn-default btn-sm" type="button" onclick="clearTime(this)" placeholder="注册时间">
                                        <i class="fa fa-remove"></i>
                                    </button>
                                </div>
                            </span>
                        <div class="input-group">
                                <span class="input-group-select">
                                    <select name="search[is_follow]" class="form-control">
                                        <option value="">关注类型</option>
                                        {volist name="memberEnum['is_follow']" id="v"}
                                        <option value="{$key}" {if(strlen($search['is_follow']) > 0 && $key == $search['is_follow'])}selected{/if}>{$v}</option>
                                        {/volist}
                                    </select>
                                </span>
                            <!--
                            <span class="input-group-select">
                                <select name="level" class="form-control">
                                    <option value="">等级</option>
                                </select>
                            </span>
                            <span class="input-group-select">
                                <select name="groupid" class="form-control">
                                    <option value="">分组</option>
                                </select>
                            </span>
                            -->
                            <span class="input-group-select">
                                    <select name="search[is_black]" class="form-control">
                                        <option value="">黑名单类型</option>
                                        {volist name="memberEnum['is_black']" id="v"}
                                        <option value="{$key}" {if(strlen($search['is_black']) > 0 && $key == $search['is_black'])}selected{/if}>{$v}</option>
                                        {/volist}
                                    </select>
                                </span>
                            <input type="text" class="form-control " name="search[keyword]" value="{$search['keyword']}" placeholder="可搜索昵称/姓名/手机号">
                            <span class="input-group-btn">
                                    <button class="btn  btn-primary" type="submit"> 搜索</button>
                                    <a class="btn btn-success" href="{:url('index')}">全部</a>
                                </span>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="box-body">
        <table class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>会员</th>
                <th>真实姓名/手机号</th>
                <th>注册时间</th>
                <!--<th>积分/余额</th>-->
                <th>是否关注/状态</th>
                <th style="width: 120px">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="datas" id="v"}
            <tr>
                <td>
                    <div rel="pop" style="display: flex" data-content="" data-original-title="" title="">
                        <img class="img-40" src="{$v['avatar']}" style="border-radius:50%;border:1px solid #efefef;" onerror="this.src='/static/admin/img/noface.png'">
                        <span style="display: flex;flex-direction: column;justify-content: center;align-items: flex-start;padding-left: 5px">
                           <span class="nickname">
                               <i class="icow icow-app" style="color: #44abf7;vertical-align: top;" data-toggle="tooltip" data-placement="bottom" data-original-title="来源: 全网通(手机号注册)"></i>
                               {$v['nickname']}
                           </span>
                       </span>
                    </div>
                </td>
                <td>
                    {$v['realname']}
                    <br>
                    {$v['mobile']}
                </td>
                <td>
                    {$v['create_time']|date='Y-m-d'}
                    <br>
                    {$v['create_time']|date='H:i:s'}
                </td>
                <!--
                <td>
                    <span>积分: <span style="color: #5097d3">{$v['integral_coin']}</span> </span>
                    <br>
                    <span>余额: <span class="text-warning">{:getMoneyForBranch($v['money_coin'])}</span></span>
                </td>
                -->
                <td>
                    {$memberEnum['is_follow'][$v['is_follow']]}
                    <br>
                    {$memberEnum['is_black'][$v['is_black']]}
                </td>
                <td>
                    <a href="{:url('edit',array('id'=>hashIdEncode($v['id'])))}">编辑</a>
                    <a class="confirm-rst-url-btn" href="{:url('del',array('id'=>hashIdEncode($v['id'])))}" data-info="你确定要删除吗？">删除</a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
    <div class="box-footer clearfix">
        <div id="page1" class="pull-right"></div>
    </div>
</div>
{/block}

{block name="script"}
<script src="https://cdn.staticfile.org/bootstrap-daterangepicker/3.0.3/moment.min.js"></script>
<script src="/static/daterangepicker/daterangepicker.js"></script>
<script>
    var totalPages = {$totalPages};
    var pageIndex = {$pageIndex};
    laypage({
        cont: 'page1', //容器。值支持id名、原生dom对象，jquery对象。【如该容器为】：<div id="page1"></div>
        pages: totalPages, //通过后台拿到的总页数
        curr: pageIndex, //当前页
        skip: true, //是否开启跳页
        jump: function(obj, first){ //触发分页后的回调
            if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                location.href = "{$pageUrl|raw}" +  "&p=" + obj.curr
            }
        }
    });
</script>
<script>
    $(function(){
        $(".daterange.daterange-time").each(function(){
            var elm = this;
            var container =$(elm).parent().prev();
            var startInput = container.find(":input:first");
            var endInput = container.find(":input:last");
            var startInputDate = startInput.val();
            var endInputDate = endInput.val();
            var dpOptions = {};
            if(startInputDate.length && endInputDate.length){
                $(elm).find(".date-title").html(startInputDate + " 至 " + endInputDate);
                dpOptions['startDate'] = startInputDate;
                dpOptions['endDate'] = endInputDate;
            }
            $(this).daterangepicker(dpOptions, function(start, end){
                var startDate = start.format('YYYY-MM-DD HH:mm');
                var endDate = end.format('YYYY-MM-DD HH:mm');
                $(elm).find(".date-title").html(startDate + " 至 " + endDate);
                startInput.val(startDate);
                endInput.val(endDate);
            });
        });
    });
    function clearTime(obj){
        $(obj).prev().data('daterangepicker').setStartDate(moment().startOf('day'));
        $(obj).prev().data('daterangepicker').setEndDate(moment().endOf('day'));
        $(obj).prev().html("<span class=date-title>" + $(obj).attr("placeholder") + "</span>");
        $(obj).parent().prev().find("input").val("");
    }
</script>
{/block}